#define _CRT_SECURE_NO_WARNINGS 1

//https://www.lanqiao.cn/courses/46292/learning/

#include<iostream>

using namespace std;

const int MAXN = 1010;

int main()
{
	int arr[MAXN][MAXN] = {0}, sum[MAXN][MAXN] = {0};
	int n = 0, m = 0, q = 0;
	cin >> n >> m >> q;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			cin >> arr[i][j];
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + arr[i][j];
		}
	}
	while (q--)
	{
		int x1 = 0, x2 = 0;
		int y1 = 0, y2 = 0;
		cin >> x1 >> y1 >> x2 >> y2;
		cout << sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1] << endl;
	}
	return 0;
}